<!DOCTYPE html>
<html>
<head>
    <title>压力测试用例文件</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" href="../../css/font-awesome.min.css">
    <link rel="stylesheet" href="../../plugins/jqgrid/ui.jqgrid-bootstrap.css">
    <link rel="stylesheet" href="../../plugins/ztree/css/metroStyle/metroStyle.css">
    <link rel="stylesheet" href="../../css/main.css">
    <link rel="stylesheet" href="../../plugins/cron/cronGen.css">
    <script src="../../libs/jquery.min.js"></script>
    <script src="../../plugins/layer/layer.js"></script>
    <script src="../../libs/bootstrap.min.js"></script>
    <script src="../../libs/vue.min.js"></script>
    <script src="../../plugins/jqgrid/grid.locale-cn.js"></script>
    <script src="../../plugins/jqgrid/jquery.jqGrid.min.js"></script>
    <script src="../../plugins/ztree/jquery.ztree.all.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../plugins/echarts/echarts.min.js"></script>
    <script src="../../plugins/echarts/theme.js"></script>
</head>
<body>
<div id="rrapp">
    <div v-show="showList">
        <div class="grid-btn">
            <div class="form-group col-sm-2">
                <input type="text" class="form-control" v-model="q.caseId" @keyup.enter="query" placeholder="用例ID">
            </div>
            <a class="btn btn-default" @click="query">查询</a>
            <a v-if="hasPermission('test:stress')" class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;配置</a>
            <a v-if="hasPermission('test:stress')" class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
            <a v-if="hasPermission('test:stress')" class="btn btn-primary" @click="stopAll"><i
                    class="fa fa-stop-circle"></i>&nbsp;全部停止</a>
            <a v-if="hasPermission('test:stress')" class="btn btn-danger" @click="stopAllNow"><i class="fa fa-stop-circle"></i>&nbsp;强制停止</a>
            &nbsp;<input type="button" class="btn btn-success" @click="reload" value="刷新"/>
            <a v-if="hasPermission('sys:schedule:save')" class="btn btn-primary" @click="addTask">&nbsp;加入任务</a>
            <a v-if="hasPermission('sys:schedule:update')" class="btn btn-primary" @click="queryTask">&nbsp;查看任务</a>
            <a v-if="hasPermission('test:stress')" class="btn btn-primary" @click="threadSet">&nbsp;线程组</a>
            &nbsp;&nbsp;<input v-if="getQueryString('CaseID')" type="button" class="btn btn-warning" @click="back" value="返回"/>
            <!--<a v-if="hasPermission('test:stress')" class="btn btn-danger" style="float:right;" href="stressTestReports.html">测试报告</a>-->
        </div>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
        <div style="text-align:center;padding-top:16px;">（说明：参数化文件或附件一定要记得同步到各个节点，如果是新追加了节点，也需要再次执行同步文件操作）</div>
    </div>

    <div v-show="showEdit" class="panel panel-default">
        <div class="panel-heading">{{title}}</div>
        <form class="form-horizontal">
            <div class="form-group">
                <div class="col-sm-2 control-label">测试报告</div>
                <label class="radio-inline">
                    <input type="radio" name="reportStatus" value="1" v-model="stressTestFile.reportStatus"/> 不需要测试报告
                </label>
                <label class="radio-inline">
                    <input type="radio" name="reportStatus" value="0" v-model="stressTestFile.reportStatus"/> 保存测试报告原始文件
                </label>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">前端监控</div>
                <label class="radio-inline">
                    <input type="radio" name="webchartStatus" value="1" v-model="stressTestFile.webchartStatus"/> 不需要前端监控
                </label>
                <label class="radio-inline">
                    <input type="radio" name="webchartStatus" value="0" v-model="stressTestFile.webchartStatus"/> 需要前端监控
                </label>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">调试报告</div>
                <label class="radio-inline">
                    <input type="radio" name="debugStatus" value="0" v-model="stressTestFile.debugStatus"/> 关闭调试
                </label>
                <label class="radio-inline">
                    <input type="radio" name="debugStatus" value="1" v-model="stressTestFile.debugStatus"/> 开启调试
                </label>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">极限时长</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="stressTestFile.duration" placeholder="单位是秒，0为永远执行"/>
                    <code style="margin-top:4px;display: block;">说明：针对永远循环的线程组，避免遗忘需设置时长(秒)<br />默认持续执行时间4小时，设置为0则表示永远循环执行！</code>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label"></div>
                <input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
                &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
            </div>
        </form>
    </div>
    <div v-show="showChart" class="panel panel-default">
        &nbsp;&nbsp;<a class="btn btn-primary" @click="startEcharts">监控启动</a>
        &nbsp;&nbsp;<a class="btn btn-primary" @click="suspendEcharts">监控暂停</a>
        &nbsp;&nbsp;<a class="btn btn-danger" @click="clearEcharts">清空数据</a>
        &nbsp;&nbsp;<a class="btn btn-warning" @click="reload">返回</a>
        <div class="panel-heading">持续时间： <span id="howLongRunningFormat"></span></div>
        <div class="panel-heading">平均响应时间(ms)</div>
        <div id="responseTimesChart"></div>
        <div class="panel-heading">每秒请求数(TPS)</div>
        <div id="throughputChart"></div>
        <div class="panel-heading">单个请求失败率</div>
        <div id="errorPercentageChart"></div>
        <div class="panel-heading">并发数信息 &nbsp;&nbsp;<span id="slaveCountFormat"></span></div>
        <div id="threadCountsChart"></div>
        <div class="panel-heading">成功率和失败率</div>
        <div id="successPercentageChart"></div>
        <div class="panel-heading">访问总数</div>
        <div id="totalCountsChart"></div>
        <div class="panel-heading">吞吐量Sent(KB/s)</div>
        <div id="networkSentChart"></div>
        <div class="panel-heading">吞吐量Received(KB/s)</div>
        <div id="networkReceivedChart"></div>
    </div>
    <div v-show="showTask" class="panel panel-default">
        <div class="panel-heading">{{title}}</div>
        <form class="form-horizontal">
            <div class="form-group">
                <div class="col-sm-2 control-label">bean名称</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="stressTestFile.beanName" :disabled="true" placeholder="spring bean名称，如：testTask"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">方法名称</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="stressTestFile.methodName" :disabled="true" placeholder="方法名称"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">参数</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="stressTestFile.params" placeholder="参数"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label" for="cron">cron表达式</div>
                <div class="col-sm-10">
                    <input v-if="showCronManual" type="text" class="form-control" v-model="stressTestFile.cronExpression" placeholder="如：0 0 12 * * ?"/>
                    <span v-show="showCronGenerate"><input id="cron" class="form-control" /></span>
                </div>
                <div class="col-sm-2 control-label"></div>
                <div class="col-sm-10" @click="chkCronEditType">
                    <label class="radio-inline">
                        <input type="radio" name="cronEditType" v-model="stressTestFile.cronEditType" value="0"/> 手工输入
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="cronEditType" v-model="stressTestFile.cronEditType" value="1"/> 编辑器输入
                    </label>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">备注</div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" v-model="stressTestFile.remark" placeholder="请备注任务说明"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label"></div>
                <input type="button" class="btn btn-primary" @click="saveTask" value="确定"/>
                &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
            </div>
        </form>
    </div>
    <div v-show="showSlave">
        <div class="grid-btn">
            <div class="form-group col-sm-2">
                <input type="text" class="form-control"  placeholder="用例ID">
            </div>
            <a class="btn btn-default" >查询</a>
            <a v-if="hasPermission('test:stress')" class="btn btn-primary" @click="runOnceNow"><i class="fa fa-pencil-square-o"></i>&nbsp;确定</a>
            &nbsp;&nbsp;<input type="button" class="btn btn-success" @click="reloadSlave" value="刷新"/>
            &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="取消"/>
            <span>&nbsp;&nbsp;【不勾选直接<确定>则表示主节点压测】</span>
        </div>
        <table id="jqSlaveGrid"></table>
        <div id="jqSlaveGridPager"></div>
        <div style="padding-top:16px;padding-top:16px;">（说明：压测前请确保参数文件已同步到各节点，否则会异常；多节点只要有一个节点异常压测进程就不能正常运行！）</div>
    </div>
</div>

<script src="../../js/modules/test/stressTestFile.js"></script>
<script src="../../plugins/cron/cronGen.min.js"></script>
</body>
</html>